/**
 * 
 */
package com.admin.his.common.helper;

import java.util.UUID;

/**
 * @author 张三
 *
 */
public interface StringHelperService {
	

	/* public */ default String uuid() {
		String uuid = UUID.randomUUID().toString();
		char[] cs = new char[32];
		for (int i = uuid.length(), j = 0; i-- > 0;) {
			if (uuid.charAt(i) != '-') {
				cs[j++] = uuid.charAt(i);
			}
		}
		return new String(cs);
	}

	default String trimAsNull(String target) {

		if (target == null || (target = target.trim()).length() == 0) {
			return null;
		}
		return target;
	}

	default Integer parseInt(String s, Integer defaultValue) {
		s=trimAsNull(s);
		if (s== null)
			return defaultValue;
		try {
			return Integer.parseInt(s);
		} catch (NumberFormatException e) {
			return defaultValue;
		}
	}
}
